/* GUI CONVERTED from rescmtb.p (converter v1.76) Wed Jan 23 14:49:48 2002 */
/* rescmtb.p    - SHOP CALENDAR MAINTENANCE SHIFT ENTRY             */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* $Revision: 1.5.1.2 $                                                         */
     /*V8:ConvertMode=Maintenance                                   */
/* REVISION: 7.0     LAST MODIFIED: 04/24/95    BY: ais *F0P6*/
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan   */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan   */
/* REVISION: 9.1      LAST MODIFIED: 08/11/00   BY: *N0J4* Mudit Mehta  */
/* $Revision: 1.5.1.2 $    BY: Annasaheb Rahane      DATE: 01/18/02  ECO: *N180*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/
{mfdeclre.i}
{gplabel.i} /* EXTERNAL LABEL INCLUDE */

define variable del-yn like mfc_logical initial no.
define shared variable ii as integer.
define shared variable mod_shifts like shop_shifts initial no.

define shared variable shft_h_start1 as character format "99:99".
define shared variable shft_h_start2 as character format "99:99".
define shared variable shft_h_start3 as character format "99:99".
define shared variable shft_h_start4 as character format "99:99".
define shared variable start_time as character.
define shared variable shop_recno as recid.

define variable i as integer.
define variable j as integer.
define variable time_hd1 as decimal format "->>>9.999".
define variable time_hm1 as character format "999:99:99".
define variable non_numeric as integer.
define variable error_flag like mfc_logical.
define variable colLabel as character no-undo extent 5.

define shared frame c1.
define shared frame c2.
define shared frame c3.
define shared frame c4.
define shared frame c5.
define shared frame c6.
define shared frame c7.

{rescfm.i c1 "SUNDAY_SHIFTS"}
{rescfm.i c2 "MONDAY_SHIFTS"}
{rescfm.i c3 "TUESDAY_SHIFTS"}
{rescfm.i c4 "WEDNESDAY_SHIFTS"}
{rescfm.i c5 "THURSDAY_SHIFTS"}
{rescfm.i c6 "FRIDAY_SHIFTS"}
{rescfm.i c7 "SATURDAY_SHIFTS"}

if shop_recno <> ?
   then find shop_cal where recid(shop_cal) = shop_recno exclusive-lock.

repeat ii = 1 to 7:
/*GUI*/ if global-beam-me-up then undo, leave.

   if mod_shifts[ii] then do:
      find shft_det where shft_mch = shop_mch
         and shft_wkctr = shop_wkctr
         and shft_site = shop_site
         and shft_day = ii no-error.

      if not available shft_det then do:
         create shft_det.
         assign
            shft_mch   = shop_mch
            shft_wkctr = shop_wkctr
            shft_site  = shop_site
            shft_day   = ii
            shft_load1 = 100
            shft_load2 = 100
            shft_load3 = 100
            shft_load4 = 100.
      end.

      shft_h_start1 = string(truncate(shft_start1,0), "99") +
                      string((shft_start1 - truncate(shft_start1,0)) * 60, "99").
      shft_h_start2 = string(truncate(shft_start2,0), "99") +
                      string((shft_start2 - truncate(shft_start2,0)) * 60, "99").
      shft_h_start3 = string(truncate(shft_start3,0), "99") +
                      string((shft_start3 - truncate(shft_start3,0)) * 60, "99").
      shft_h_start4 = string(truncate(shft_start4,0), "99") +
                      string((shft_start4 - truncate(shft_start4,0)) * 60, "99").

      timeloop:
      repeat:
/*GUI*/ if global-beam-me-up then undo, leave.

         if ii = 1 then
            update shft_h_start1 shft_hour1 shft_pat1 shft_load1
                   shft_h_start2 shft_hour2 shft_pat2 shft_load2
                   shft_h_start3 shft_hour3 shft_pat3 shft_load3
                   shft_h_start4 shft_hour4 shft_pat4 shft_load4
                   go-on ("F5" "CTRL-D")
            with frame c1.

         if ii = 2 then
            update shft_h_start1 shft_hour1 shft_pat1 shft_load1
                   shft_h_start2 shft_hour2 shft_pat2 shft_load2
                   shft_h_start3 shft_hour3 shft_pat3 shft_load3
                   shft_h_start4 shft_hour4 shft_pat4 shft_load4
                   go-on ("F5" "CTRL-D")
            with frame c2.

         if ii = 3 then
            update shft_h_start1 shft_hour1 shft_pat1 shft_load1
                   shft_h_start2 shft_hour2 shft_pat2 shft_load2
                   shft_h_start3 shft_hour3 shft_pat3 shft_load3
                   shft_h_start4 shft_hour4 shft_pat4 shft_load4
                   go-on ("F5" "CTRL-D")
            with frame c3.

         if ii = 4 then
            update shft_h_start1 shft_hour1 shft_pat1 shft_load1
                   shft_h_start2 shft_hour2 shft_pat2 shft_load2
                   shft_h_start3 shft_hour3 shft_pat3 shft_load3
                   shft_h_start4 shft_hour4 shft_pat4 shft_load4
                   go-on ("F5" "CTRL-D")
            with frame c4.

         if ii = 5 then
            update shft_h_start1 shft_hour1 shft_pat1 shft_load1
                   shft_h_start2 shft_hour2 shft_pat2 shft_load2
                   shft_h_start3 shft_hour3 shft_pat3 shft_load3
                   shft_h_start4 shft_hour4 shft_pat4 shft_load4
                   go-on ("F5" "CTRL-D")
            with frame c5.

         if ii = 6 then
            update shft_h_start1 shft_hour1 shft_pat1 shft_load1
                   shft_h_start2 shft_hour2 shft_pat2 shft_load2
                   shft_h_start3 shft_hour3 shft_pat3 shft_load3
                   shft_h_start4 shft_hour4 shft_pat4 shft_load4
                   go-on ("F5" "CTRL-D")
            with frame c6.

         if ii = 7 then
            update shft_h_start1 shft_hour1 shft_pat1 shft_load1
                   shft_h_start2 shft_hour2 shft_pat2 shft_load2
                   shft_h_start3 shft_hour3 shft_pat3 shft_load3
                   shft_h_start4 shft_hour4 shft_pat4 shft_load4
                   go-on ("F5" "CTRL-D")
            with frame c7.

         start_time = substring(shft_h_start1,1,2) + ":" +
                      substring(shft_h_start1,3,2).

         {mftimec2.i start_time}
         if error_flag then next.
         shft_start1 = time_hd1.

         {mftimec2.i shft_h_start2}
         if error_flag then next.
         shft_start2 = time_hd1.

         {mftimec2.i shft_h_start3}
         if error_flag then next.
         shft_start3 = time_hd1.

         {mftimec2.i shft_h_start4}
         if error_flag then next.
         shft_start4 = time_hd1.

         leave.
      end.
/*GUI*/ if global-beam-me-up then undo, leave.


      assign shop_wday[ii]   = true
             shop_shifts[ii] = true
             shop_hours[ii]  = shft_hour1 + shft_hour2 +
                               shft_hour3 + shft_hour4.

      if lastkey = keycode("F5") or lastkey = keycode("CTRL-D") then do:
         del-yn = yes.
         {pxmsg.i &MSGNUM=11 &ERRORLEVEL=1 &CONFIRM=del-yn}
         if not del-yn then undo, retry.
         shop_shifts[ii] = false.
         shop_hours[ii] = 0.
         shop_wday[ii] = false.
         delete shft_det.
         if ii = 1 then clear frame c1.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame c1 = F-c1-title.
         if ii = 2 then clear frame c2.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame c2 = F-c2-title.
         if ii = 3 then clear frame c3.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame c3 = F-c3-title.
         if ii = 4 then clear frame c4.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame c4 = F-c4-title.
         if ii = 5 then clear frame c5.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame c5 = F-c5-title.
         if ii = 6 then clear frame c6.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame c6 = F-c6-title.
         if ii = 7 then clear frame c7.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame c7 = F-c7-title.
         del-yn = no.
      end.
   end. /* modify shifts = yes. */

   if ii = 1 then hide frame c1.
   if ii = 2 then hide frame c2.
   if ii = 3 then hide frame c3.
   if ii = 4 then hide frame c4.
   if ii = 5 then hide frame c5.
   if ii = 6 then hide frame c6.
   if ii = 7 then hide frame c7.

end.
/*GUI*/ if global-beam-me-up then undo, leave.

